<?php

class Application_Form_Comment extends Zend_Form {

    public function init() {
        $this->setMethod('post')
                ->setAttrib('id', 'commentForm')
                ->addElementPrefixPath('ZendBlog_Validate', 'ZendBlog/validate/', 'validate')
                ->addElementPrefixPath('ZendBlog_Filter', 'ZendBlog/filter/', 'filter')
                ->setDecorators(ZendBlog_Decorator_Decorator::Form());

        /* Name */
        $this->addElement('text', 'name', array(
            'decorators' => ZendBlog_Decorator_Decorator::Element(),
            'label' => 'Name',
            'validators' => array(
                array('stringLength', false, array(3, 100))
            ),
            'attribs' => array(
                'maxlength' => 100,
                'size' => 20
            ),
            'required' => true
        ));

        /* Uri */
        $this->addElement('text', 'url', array(
            'decorators' => ZendBlog_Decorator_Decorator::Element(),
            'label' => 'Website',
            'validators' => array(
                array('uri')
            ),
            'attribs' => array(
                'maxlength' => 100,
                'size' => 20
            ),
        ));

        /* Comment */
        $this->addElement('textarea', 'comment', array(
            'decorators' => ZendBlog_Decorator_Decorator::Element(),
            'label' => 'Comment',
            'filters' => array('HtmlComment'),
            'attribs' => array(
                'maxlength' => 500,
                'cols' => 35,
                'rows' => 10
            ),
            'required' => true
        ));

        /* Note */
        $this->addElement('note', 'note', array(
            'decorators' => ZendBlog_Decorator_Decorator::Element()
        ));

        /* Captcha */
        $this->addElement('captcha', 'captcha', array(
            'decorators' => ZendBlog_Decorator_Decorator::Element(),
            'label' => "Verify captcha",
            'captcha' => array(
                'captcha' => 'image',
                'font' => './font/ARLRDBD.ttf',
                'imgDir' => './captcha/',
                'imgUrl' => 'http://' . $_SERVER['SERVER_NAME'] . '/captcha/',
                'wordLen' => 4,
                'fsize' => 30,
                'height' => 40,
                'width' => 150,
                'gcFreq' => 10,
                'expiration' => 300
            )
        ));

         /* Post button */
        $this->addElement('submit', 'Post', array(
            'decorators' => ZendBlog_Decorator_Decorator::Submit()
        ));

        /* Hidden Id */
        $this->addElement('hidden', 'id', array(
            'validators' => array('Digits'),
            'required' => true
        ));

    }
}

